#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   renren_gui.py
@Time    :   2019/08/02 11:25:18
@Author  :   JIAWEI GAO
@Contact :   jiawei.goah@gmail.com
@TODO    :   Have a good day!
'''

from tkinter import *
import tkinter.messagebox as message_box
from renren_spider import renren_handler

class Application(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master=None)
        self.pack()
        self.createWidgets()

    def createWidgets(self):
        self.alert_label = Label(self, text = 'Please Input Your File Name Below!')
        self.alert_label.pack()
        self.name_input = Entry(self)
        self.name_input.pack()
        self.start_button = Button(self, text='Start', command=self.start_spider)
        self.start_button.pack()

    def start_spider(self):
        name = self.name_input.get() or 'wordlist'
        spider = renren_handler(name)
        spider.get_data()
        message_box.showinfo('Finished!', 'Spider is Finished, Close this Window!')
        self.quit()

if __name__ == "__main__":
    app = Application()
    # 设置窗口标题:
    app.master.title('Renren Spider')
    # 主消息循环:
    app.mainloop()